package cn.java81;

import cn.java81.util.DbUtil;

import java.sql.*;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws SQLException {
        Connection connection = DbUtil.getConnection();
        System.out.println(connection.getClass().getName());
        System.out.println("元信息：");
        DatabaseMetaData metaData = connection.getMetaData();
        System.out.println(metaData.getDatabaseProductName());
        System.out.println(metaData.getDatabaseProductVersion());
        System.out.println(metaData.getDriverName());
        System.out.println(metaData.getDriverMajorVersion());
        PreparedStatement ps=connection.prepareStatement("select * from s_student");

        ResultSet rs = ps.executeQuery();
        ResultSetMetaData rm = rs.getMetaData();
        System.out.println(rm.getTableName(1));
        System.out.println("有多少列："+rm.getColumnCount());
        System.out.println("有哪些列：");
        for(int i=1;i<=rm.getColumnCount();i++){
            System.out.println(rm.getColumnLabel(i)+","+rm.getColumnTypeName(i)+",对应的java类型："+rm.getColumnClassName(i));
        }
        DbUtil.close(rs);
        DbUtil.close(ps);
        DbUtil.close(connection);//

    }
}
